📒 gpu-allocator
[]
= "0.22.0"
This crate provides a fully written in Rust memory allocator for Vulkan and DirectX 12.
Windows-rs and winapi
gpu-allocator
recently migrated from winapi to windows-rs but still provides convenient helpers to convert to and from winapi types, enabled when compiling with the public-winapi
crate feature.
Setting up the Vulkan memory allocator
use *;
let mut allocator = new;
Simple Vulkan allocation example
use *;
use MemoryLocation;
// Setup vulkan info
let vk_info = builder
.size
.usage;
let buffer = unsafe .unwrap;
let requirements = unsafe ;
let allocation = allocator
.allocate.unwrap;
// Bind memory to the buffer
unsafe ;
// Cleanup
allocator.free.unwrap;
unsafe ;
Setting up the D3D12 memory allocator
use *;
let mut allocator = new;
Simple d3d12 allocation example
use *;
use MemoryLocation;
let buffer_desc = D3D12_RESOURCE_DESC ;
let allocation_desc = from_d3d12_resource_desc;
let allocation = allocator.allocate.unwrap;
let mut resource: = None;
let hr = unsafe ?;
// Cleanup
drop;
allocator.free.unwrap;
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Alternative libraries
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.